<script>
  new Number(1) instanceof Number
  new Number(1) instanceof Object;
  (() => {}) instanceof Function;
  (() => {}) instanceof Object
  // 左边的对象 是 右边构造函数的实例对象
  // true / false

  // obj.__proto__([[Prototype]])原型链属性 ->  ctro.prototype

  // let obj = {}
  // let ctor = {}

  // obj instanceof ctor // false
  // ctor.prototype = {}
  // Object.setPrototypeOf(obj, ctor.prototype)

  // let f1 = () => {};
  // let f2 = function () {}
  // obj instanceof f1;
  // obj instanceof f2






  let obj = {}
  class ctor {}
  console.log(obj instanceof ctor);
  Object.setPrototypeOf(obj, new ctor)
  console.log(obj instanceof ctor);


  function instaceOf(obj, ctor) {
    if (!(obj && typeof obj === 'object')) return false
    let proto = Object.getPrototypeOf(obj)
    return proto === ctor.prototype ||
      instaceOf(proto, ctor)
  }
</script>